package com.spring5.learning.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;

/**
 * @author xin
 * @version 1.0
 */
public class LoggerBeanPostProcessor implements BeanPostProcessor, Ordered {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("Bean `" + beanName + "` created: " + bean.toString());
        return bean;
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
